---@diagnostic disable: undefined-global

--- 心战技能
--- 你可如手牌般使用其他角色明置的红桃牌。
local xinzhan = fk.CreateSkill{
  name = "lvshi__xinzhan",
  frequency = "skill",
}

local DIY = require "packages/diy_utility/diy_utility"

xinzhan:addEffect("filter", {
  handly_cards = function (self, player)
    if player:hasSkill(xinzhan.name) then
      local handly_cards = {}
      -- 检查是否有其他角色明置的红桃牌
      local room = Fk:currentRoom()
      for _, p in ipairs(room.alive_players) do
        if player ~= p then
          local heart_cards = table.filter(DIY.getShownCards(p), function(id)
            return Fk:getCardById(id).suit == Card.Heart end)
          table.insertTable(handly_cards, heart_cards)
        end
      end
      return handly_cards
    end
  end,
})


Fk:loadTranslationTable{
  ["lvshi__xinzhan"] = "心战",
  [":lvshi__xinzhan"] = "你可如手牌般使用其他角色明置的红桃手牌。",
  
  ["$lvshi__xinzhan1"] = "攻心为上，攻城为下。",
  ["$lvshi__xinzhan2"] = "知己知彼，百战不殆。",
}

return xinzhan